package util.src.com;

import java.io.*;

/**
 * @Author: Gosin
 * @Date: 2020/10/29 10:15
 * 从fromPath处读fromName文件，经过selectUrl方法的挑选，输出到toPath的toName文件
 */
public class WriteText {
    public String fromPath;
    public String fromName;
    public String toPath;
    public String toName;

    public WriteText(String fromPath, String fromName, String toPath, String toName) {
        this.fromPath = fromPath;
        this.fromName = fromName;
        this.toPath = toPath;
        this.toName = toName;
    }

    public WriteText() {
    }

    public void getTsUrlText() throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fromPath + fromName)));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(toPath + toName)));
        String line;
        String mag;

        while ((line = reader.readLine()) != null) {
            mag = selectUrl(line);
            if (mag != null) {
                writer.write(mag + "\n");
            }
        }
        writer.close();
        reader.close();
    }

    protected String selectUrl(String line) {
        return null;
    }

}